import 'package:flutter/material.dart';

class TipRoute extends StatelessWidget {
  final String text;

  const TipRoute({Key? key, required this.text}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    // 获取路由参数
    var args = ModalRoute.of(context)!.settings.arguments;
    return Scaffold(
      appBar: AppBar(
        title: Text(args != null ? args.toString() : text),
      ),
      body: Padding(
        padding: const EdgeInsets.all(18),
        child: Center(
          child: Column(
            children: [
              Text(text),
              ElevatedButton(
                child: const Text("返回"),
                onPressed: () => Navigator.of(context).pop("我是返回值"),
              ),
            ],
          ),
        ),
      ),
    );
  }
}
